package com.example.badyloans.common;

import com.sun.org.apache.bcel.internal.classfile.Code;
import io.swagger.annotations.ApiModel;
import org.springframework.data.domain.Page;
import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 * @author 啊桥哦
 * @Description: 自定义返回结果
 * @date 2020-07-12 19:58
 */
@ApiModel("自定义返回结果集")
public class ReturnResult implements Serializable {

    private static final long serialVersionUID = -4179966297881524874L;

    private String code;

    private String msg;

    private Object data;

    private Object pages;

    public Object getPages() {
        return pages;
    }

    public void setPages(Object pages) {
        this.pages = pages;
    }

    public static ReturnResult succes(){
       return success(null,null);
    }

    public static ReturnResult success(Object data,Object pages){
        return new ReturnResult("200","操作成功", data,pages);
    }

    public static ReturnResult fail(){
        return new ReturnResult("500","操作失败",null, null);
    }

    public static ReturnResult fail(String msg){
        return new ReturnResult("500",msg,null,null);
    }
    public static ReturnResult fail(String code,String msg){
        return new ReturnResult("404",msg,null,null);
    }

    private ReturnResult(String code,String msg, Object data,Object pages){
        this.code=code;
        this.msg=msg;
        this.data=data;
        this.pages=pages;
    }
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
